<?php

/**
 * Description of pagomatricula_model
 * @author Machete
 */
class Pagomatricula_model extends CI_Model {

    //put your code here

    function get_listado() {
        $this->db->select('a.id, a.monto, b.nombre');
        $this->db->from('pagomatricula a, carrera b');
        $this->db->where('a.idcarrera = b.id');
        $this->db->group_by('id');
        $query = $this->db->get('pagomatricula');
        return $query;
    }

    function get_listado_1($registros_por_pagina, $uri_segment) {
        $this->db->select('a.id, a.monto, b.nombre');
        $this->db->from('pagomatricula a, carrera b');
        $this->db->where('a.idcarrera = b.id');
        $query = $this->db->get('', $registros_por_pagina, $uri_segment);
        return $query;
    }

    function get_total_registros() {
        return $this->db->count_all('pagomatricula');
    }

    function get_datos_registro($id) {
        $this->db->select('id, monto, idcarrera');
        $this->db->where('id', $id);
        $query = $this->db->get('pagomatricula');
        return $query->result();
    }

    function guardar($monto, $idcarrera) {
        $datos = array(
            'monto' => $monto,
            'idcarrera' => $idcarrera
        );
        $this->db->insert('pagomatricula', $datos);
    }

    function actualizar($codigo, $monto, $idcarrera) {
        $datos = array(
            'monto' => $monto,
            'idcarrera' => $idcarrera
        );
        $this->db->where('id', $codigo);
        $this->db->update('pagomatricula', $datos);
    }

    function eliminar($codigo) {
        $this->db->delete('pagomatricula', array('id' => $codigo));
    }

    function buscar($palabras) {
        $this->db->select('a.id, a.monto, b.nombre');
        $this->db->from('pagomatricula a, carrera b');
        $this->db->where('a.idcarrera = b.id');
        $this->db->like('monto', $palabras);
        $query = $this->db->get('');
        return $query;

//        $query = $this->db->query("SELECT * FROM pagomatricula WHERE monto LIKE '%" . $palabras . "%'");
  //      return $query;
    }

}

?>
